<?php
import('ORG.Net.UploadFile');
import('@.Common.NoticeUrl');
class NoticeImageUploader extends UploadFile{
    static $_CONST=array(
        'TYPE_POSTER'=> 'poster',
        'TYPE_EVENT_IMAGE'=>    'event',
    );
    static public function C($name){
        return self::$_CONST[$name];
    }
    
    public function NoticeImageUploader(){
        parent::__construct();
        $this->autoCheck= true; //自动检测附件
        $this->maxSize= 1024*1024*3;
        $this->saveRule= 'uniqid';
        $this->uploadReplace= true;
        $this->allowTypes= array('image/bmp', 'image/gif', 'image/jpeg', 'image/x-png', 'image/png', 'image/pjpeg', 'image/tiff', 'image/svg+xml');
        //设置缩略图
        $this->thumb= true;
        $this->thumbMaxWidth= '150';
        $this->thumbMaxHeight= '180';   //必须同时指定否则无法缩放
        $this->thumbPrefix= 'm_';
        $this->thumbRemoveOrigin= false;
        $this->autoSub= false;       //自动创建子目录保存文件
    }
    public function uploadEventPoster($file=null){
        $this->savePath= NoticeUrl::realEventPoster();
        return $this->upload();
    }
    public function uploadEventImage($file=null){
        $this->savePath= NoticeUrl::realEventImage();
        return $this->upload();
    }
}
?>
